<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //网站的几个人的爱好，可以用算法来查看(有无共同爱好)
        let set1=new Set([1,5,4,6,8,2]);
        let set2=new Set([1,6,7,5,22,74]);

        //两个人的全部爱好
        let new_hoby=new Set([...set1,...set2]);
        console.log(new_hoby);//{1, 5, 4, 6, 8, …}
        //两个人的差集(set1-set2 ),set1中有，set2中没有的
        let diff_hoby=[...set1].filter(item=> !(set2.has(item)) )
        console.log(diff_hoby);//[4, 8, 2]
        //两个人的共同爱好
        let com_hoby=[...set1].filter(item=> (set2.has(item)) )
        console.log(com_hoby);//[1,5,6]
    </script>
</body>
</html>